package com.ynny.bean;

import com.ynny.dao.Course;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;

public class CourseManageimpl implements CourseManage {

    @Autowired
    JdbcTemplate jdbcTemplate;
    @Override
    public void updateCourse(String courseName) {
        String sql = "update course set + courseName =  courseName  + courseName + 1";
        int num = jdbcTemplate.update(sql);
        if (num <= 0)
            System.out.println("更新失败");


    }

    @Override
    public void queryCourse() {
        String sql = "select * from course";
        Course course = jdbcTemplate.queryForObject(sql, new BeanPropertyRowMapper<Course>(Course.class))
        System.out.println(course);
    }

    @Override
    public void selectCourse(String number, String courseName) {
        updateCourse(courseName);
        queryCourse();
        String sql = "insert into selectcourse values(?,?)";
        jdbcTemplate.execute(sql);
        System.out.println("选课成功");


    }
    }

